﻿using TjZheng.Example.MVC.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TjZheng.Framework;

namespace TjZheng.Example.MVC.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
            //string str = string.Format("{0}");
            //return View("~/Views/Action/MainAction.cshtml");
        }

        public ActionResult SimpleIndex()
        {
            return View();
        }

        public ActionResult ComplicatedIndex()
        {
            return View();
        }

        public ActionResult ArrayIndex()
        {
            return View();
        }

        public ActionResult DictIndex()
        {
            return View();
        }

        public ActionResult JsonIndex()
        {
            return View();
        }

        [HttpPost]
        public ActionResult PostParams(string foo, string zoo, string bar, string baz)
        {
            return Json(foo);
        }

        [HttpPost]
        public ActionResult PostEntity(FooEntity objFooEntity, string foo, string zoo)
        {
            return Json(objFooEntity.foo);
        }

        [HttpPost]
        public ActionResult PostSimpleEntity(ZooEntity objZooEntity)
        {
            //转化失败
            return Json(objZooEntity);
        }

        [HttpPost]
        public ActionResult PostComplicatedEntity(FooEntity objFooEntity)
        {
            return Json(objFooEntity.zooEntity.zoo);
        }

        [HttpPost]
        public ActionResult PostList(IList<FooEntity> fooList)
        {
            return Json(fooList.Count);
        }

        [HttpPost]
        public ActionResult PostDict(Dictionary<string, FooEntity> fooDict)
        {
            return Json(fooDict.Count);
        }

        [HttpPost]
        public ActionResult PostJson(FooEntity objFooEntity)
        {
            return Json(objFooEntity.zooEntity.zoo);
        }
        public ActionResult Form()
        {
            return View();
        }

        public ActionResult Submit(string myzoo)
        {
            return Content(myzoo);
        }
    }
}
